package JavaEE.NetWork.UDP;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;

// 翻译服务器~
// 主要逻辑和"回显服务器"一样,只需要重写"构造响应"的方法即可.
public class DictServer extends EchoServer{
    private HashMap<String,String> map = new HashMap<>();
    public DictServer(int num) throws SocketException {
        super(num);

        map.put("cat","猫");
        map.put("dog","狗");
    }
    @Override
    public String process(String request){
        //return request;
        return map.getOrDefault(request,"该单词没有找到");
    }

    public static void main(String[] args) throws IOException {
        DictServer server = new DictServer(9090);
        server.start();
    }
}




